package com.ccoffers.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.ccoffers.model.cardinfo.CreditCardType;
import com.ccoffers.service.impl.CRUDServiceImpl;

@Controller
@RequestMapping(value="/cardType")
public class CreditCardTypeAdminController {
	@Autowired
	private CRUDServiceImpl<CreditCardType> creditCardTypeService;
	
	@RequestMapping(value="/add")
	public String addCardType(@RequestParam("cardType") String cardType, Model model){
		CreditCardType creditCardType = new CreditCardType();
		creditCardType.setCardType(cardType);
		creditCardTypeService.update(creditCardType);
		return "redirect:/internal/admin";
	}
	
	@RequestMapping(value="/delete")
	public String deleteCreditCardCompany(@RequestParam("id") Long id, Model model){
		creditCardTypeService.delete(creditCardTypeService.retrieve(CreditCardType.class, id));
		return "redirect:/internal/admin";
	}
}
